home *** CD-ROM | disk | FTP | other *** search
- /*
- property is © 1996 Boxes Objects Links Design Pty Ltd. All Rights Reserved.
- You use this software at your own risk, etc. Permission is given to Timothy C.
- Delaney to use property. Permission is given for all others to use property if
- acknowledgement of this copyright is given in publically-released software.
- Acknowledgement should consist of a statement equivalent to "Sections of this
- program are © Boxes Objects Links Design Pty Ltd", visible in an "About..." box
- or splash screen.
- */
-
- #ifndef _H_property
- #define _H_property
-
- #include <bool.h>
-
- enum EPropertyAccess
- {
- propertyAccess_ReadOnly = 'PAR0',
- propertyAccess_WriteOnly = 'PA0W',
- propertyAccess_ReadWrite = 'PARW'
- };
-
- template <EPropertyAccess access, class T>
- class property
- {
- public:
-
- property (void * const theObject,
- T &field );
-
- property (void * const theObject,
- void (*getFunc) (void * const, T & ) );
-
- property (void * const theObject,
- void (*setFunc) (void * const, const T & ) );
-
- property (void * const theObject,
- T &getField,
- T &setField );
-
- property (void * const theObject,
- void (*getFunc) (void * const, T & ),
- T &setField );
-
- property (void * const theObject,
- T &getField,
- void (*setFunc) (void * const, const T & ) );
-
- property (void * const theObject,
- void (*getFunc) (void * const, T & ),
- void (*setFunc) (void * const, const T & ) );
-
- virtual ~property (void );
-
- operator T (void );
- property & operator= (const T &newValue );
- property & operator= (property<access, T> newProperty );
-
- property & operator+= (const T &newValue );
- property & operator-= (const T &newValue );
- property & operator*= (const T &newValue );
- property & operator/= (const T &newValue );
-
- private:
-
- enum EInternalAccess
- {
- internalAccess_None,
- internalAccess_Field,
- internalAccess_Func
- };
-
- union UPropertyGet
- {
- T *mGetField;
- void (*mGetFunc) (void *, T & );
- };
-
- union UPropertySet
- {
- T *mSetField;
- void (*mSetFunc) (void *, const T & );
- };
-
- void * const mObject;
-
- EInternalAccess mGetAccess,
- mSetAccess;
-
- UPropertyGet mGet;
- UPropertySet mSet;
-
- bool Readable (void );
- bool Writeable (void );
-
- bool ReadFunc (void );
- bool WriteFunc (void );
-
- void ThrowAccess_(void ) throw (EPropertyAccess);
- void MatchAccess_(void ) throw (EPropertyAccess);
- };
-
- #include "property.cp"
-
- #endif
-